import java.awt.List;
import java.util.ArrayList;
import java.util.Collections;


public class Rank {
	
	public int Index;
	public int CardNumbers;
	public ArrayList<String> Hand = new ArrayList<String>();
	public ArrayList<String> Hand2 = new ArrayList<String>();
	public ArrayList<Integer> POM = new ArrayList<Integer>();
	public ArrayList<Integer> POM2 = new ArrayList<Integer>();
	public Card[] HD;
	public int[] CardBool = new int[4];
	
	
	Rank(Card[] H,int k){
		HD = H;
		Index = k;
		
		for(int i =0;i<=3;i++){
			Hand.add(H[i].CardFigure()+"");
			POM.add(H[i].CardValue());
			CardBool[i]=1;
		}
		
		System.out.println("COnstructor finished job");
	}	
	
	public void Resort(){
		//First we need to take care of same figures
		int p =0;
		for(int i=0;i<=2;i++)
			for(int j=i+1;j<=3;j++)
				if(CardBool[i]!=0)
				 if( (HD[i].CardColour()+"").equals(HD[j].CardColour()+""))
					if(CardBool[j]!=0)
						if(POM.get(i) > POM.get(j)){
							CardBool[i]=0;
							i=i+1;
							j=i+1;}
						else
							CardBool[j]=0;
		
		
		
		System.out.println("FIRST STEP FINISHED");
		
		for(int i=0;i<=2;i++)
			for(int j=i+1;j<=3;j++)
			  if(CardBool[i]!=0)
				if( (HD[i].CardFigure()+"").equals(HD[j].CardFigure()+""))
					if(CardBool[j]!=0)
						CardBool[j]=0;

		for(int j=0;j<=3;j++)
			if(CardBool[j]!=0){
				Hand2.add(Hand.get(j));
				POM2.add(POM.get(j));}


				
		//We removed all same figures
		
		
		//Now we hve our Hand arraylist. last thing we need is to sort it.
		
	//we have Hand-list
	//we have POM list
	
		Collections.sort(POM2);
		CardNumbers = POM2.size();
		for(int i =0;i<=Hand2.size()-1;i++)
			System.out.println(": "+ Hand2.get(i));
		
	}
	
	public void PRINT(){
		for(int i =0;i<=Hand.size()-1;i++)
			System.out.println(": "+ Hand.get(i));
	}
	//wazne metody
	public int CardNr(){
		return CardNumbers;
	}
	
	public ArrayList<Integer> NrHand(){
		return POM2;
	}
	public ArrayList<String> Hand(){
		return Hand2;
	}
	
	public int Index(){
		return Index;
	}
}
	
